<template>
  <transition name="fade">
    <div
        v-if="modelValue"
        class="customer-service-modal"
        @click.self="close"
    >
      <div class="cs-container">
        <!-- 客服窗口头部 -->
        <div class="cs-header">
          <h3><el-icon><ChatLineRound /></el-icon> 在线客服</h3>
          <el-icon class="close-btn" @click="close"><Close /></el-icon>
        </div>

        <!-- 客服内容区 -->
        <div class="cs-content">
          <div class="contact-card">
            <div class="contact-method">
              <el-icon class="icon"><ChatLineRound /></el-icon>
              <div class="info">
                <p class="title">微信客服</p>
                <!-- 直接显示二维码，移除PaperService文本和按钮 -->
                <div class="qr-code-wrapper">
                  <img
                      src="/wx.png"
                      alt="微信二维码"
                      class="qr-code"
                  >
                  <p class="qr-tip">扫码添加客服微信</p>
                </div>
              </div>
            </div>
          </div>

          <!-- 工作时间 -->
          <div class="work-time">
            <el-icon><Clock /></el-icon>
            <span>工作时间：9:00-20:00</span>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
import {
  ChatLineRound,
  Clock,
  Close
} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'

export default {
  props: {
    modelValue: {
      type: Boolean,
      required: true
    }
  },
  emits: ['update:modelValue'],
  components: { ChatLineRound, Clock, Close },
  setup(props, { emit }) {
    const close = () => {
      emit('update:modelValue', false)
    }

    return {
      close
    }
  }
}
</script>

<style scoped>
/* 入场动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
  transform: translateY(20px);
}

/* 客服窗口样式 */
.customer-service-modal {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  z-index: 2000;
  padding: 20px;
  box-sizing: border-box;
}

.cs-container {
  width: 360px;
  max-height: 80vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #007aff, #005bb5);
  color: white;
}

.cs-header h3 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  cursor: pointer;
  font-size: 18px;
  transition: transform 0.2s;
}

.close-btn:hover {
  transform: rotate(90deg);
}

.cs-content {
  padding: 20px;
  overflow-y: auto;
  flex-grow: 1;
}

.contact-card {
  background: #f9fafc;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.contact-method {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20px;
}

.contact-method:last-child {
  margin-bottom: 0;
}

.icon {
  font-size: 24px;
  color: #007aff;
  margin-right: 16px;
  margin-top: 2px;
  flex-shrink: 0;
}

.info {
  flex-grow: 1;
}

.title {
  font-size: 14px;
  color: #666;
  margin: 0 0 10px 0;
  text-align: center;
}

.qr-code-wrapper {
  text-align: center;
  margin: 12px 0;
  padding: 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid #eee;
}

.qr-code {
  width: 160px;
  height: 160px;
  display: block;
  margin: 0 auto;
}

.qr-tip {
  font-size: 12px;
  color: #999;
  margin: 8px 0 0;
}

.work-time {
  font-size: 13px;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px dashed #eee;
}
</style>